package com.situ.mall.common.mapper;

import com.situ.mall.common.entity.Cart;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.situ.mall.common.entity.Cart;
import com.situ.mall.common.vo.CartVO;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author membergpf
 * @since 2023-03-18
 */
public interface CartMapper extends BaseMapper<Cart> {
        List<Cart> selectAll();
@Select("select *  from cart where product_id=#{productId} and member_id=#{id}")
    Cart selectByMemberIdAndProdunctId(@Param("id") Integer id, @Param("productId") Integer productId);
@Update("update cart set amount =amount+1 where id=#{id}")
    void updateAmount(Integer id);
@Select("select cart.*,product.firstimg 'productImg',product.name 'productName',product.price from cart  inner join product on product.id=cart.product_id where member_id =#{id}")
    List<CartVO> selectCartList(Integer id);
@Update("update cart set amount = #{num} where id=#{id}")
    void updateAmount(@Param("id") Integer cartid, @Param("num") Integer num);
@Select("select cart.*,product.firstimg 'productImg', product.name 'productName',product.price from cart inner join product on product.id = cart.product_id where member_id = #{id} and cart.id=#{parseInt}")
CartVO selectOrderList(@Param("parseInt")int parseInt,@Param("id") Integer id);
}
